package com.kfm.order.service.impl;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.digest.MD5;
import org.apache.commons.codec.digest.Md5Crypt;
import org.springframework.stereotype.Service;

import org.springframework.beans.factory.annotation.Autowired;

import com.kfm.common.domain.entity.Member;
import com.kfm.order.mapper.MemberMapper;
import com.kfm.order.service.MemberService;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MemberServiceImpl implements MemberService{

    @Resource
    private MemberMapper memberMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return memberMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Member record) {
        return memberMapper.insert(record);
    }

    @Override
    public int insertSelective(Member record) {
        record.setPassword(SecureUtil.md5(record.getPassword()));
        return memberMapper.insertSelective(record);
    }

    @Override
    public Member selectByPrimaryKey(Integer id) {
        return memberMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Member record) {
        return memberMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Member record) {
        return memberMapper.updateByPrimaryKey(record);
    }

    @Override
    public Member login(String username, String password) {
        return memberMapper.selectByUsernameAndPassword(username, SecureUtil.md5(password));
    }

    @Override
    public List<Member> selectAll() {
        return memberMapper.selectAll();
    }

}
